package com.stockz.portfolio.dao;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;

import com.stockz.portfolio.domain.model.Holding;

public class PortfolioDao {

	private EntityManager entityManager;
	
	public double getCurrentValue(List<Holding> holdings){
		double value = 0;
		if(holdings != null && !holdings.isEmpty()){
			List<String> scripCodes = new ArrayList<String>(holdings.size());
			for(Holding holding : holdings){
				scripCodes.add(holding.getScrip().getCode());
			}
			entityManager.createQuery("select sum(val) from(select max(b.close) as val from Bar b where b.code in :scripCodeList group by b.code)");
			
		}
		return value;
	}
	
}
